<template>
  <a-card :bordered="false">
      <!-- 查询区域 -->
    <div class="table-page-search-wrappe">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="团队名称">
              <select-team-input
                :multi="true"
                placeholder="请选择团队"
                v-model="queryParam.teamIdList"
                :teamType="0"
                :tdlx="3"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="职位">
              <j-dict-select-tag
                placeholder="请选择职位"
                v-model="queryParam.postId"
                dictCode="sys_position,name,id"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="11" :md="12" :sm="24">
            <a-form-item label="所属月份">
              <a-month-picker v-model="queryParam.month" placeholder="请选择所属月份" valueFormat="YYYY-MM" picker="month" style="width: 100%;"></a-month-picker>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
<!--              <a @click="handleToggleSearch" style="margin-left: 8px">-->
<!--                {{ toggleSearchStatus ? '收起' : '展开' }}-->
<!--                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>-->
<!--              </a>-->
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button type="primary" icon="download" @click="handleExportXls('月份人员需求统计表')" :disabled="isDisabledAuth('hrReportEmployeeRequirements:export')">导出</a-button>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:'100%'}"
        :components="draggableComponent"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        :customRow="customRow"
        @change="handleTableChange">
        <template slot="status" slot-scope="status">
           <a-badge :status="status | statusTypeFilter" :text="status | statusFilter"/>
        </template>
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

      </a-table>
    </div>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import {DisabledAuthFilterMixin} from '@/mixins/DisabledAuthFilterMixin'
  import SelectTeamInput from '@/views/scy/components/SelectTeamInput'
  import moment from 'moment';
  export default {
    name: 'HrReportEmployeeRequirementsList',
    mixins:[JeecgListMixin, mixinDevice, DisabledAuthFilterMixin],
    components: {
      SelectTeamInput
    },
    data () {
      return {
        description: 'hr_report_employee_requirements管理页面',
        //表头
        columns:[],
        //列设置
        settingColumns:[],
        // 列定义
        defColumns: [
          {
            title: '序号',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'所属月份',
            align:"center",
            width:200,
            dataIndex: 'updateTime',
            ellipsis: true
          },
          {
            title:'团队',
            align:"center",
            width:200,
            dataIndex: 'teamName',
            ellipsis: true
          },
          {
            title:'职位',
            align:"center",
            width:200,
            dataIndex: 'postName',
            ellipsis: true
          },
          {
            title:'需求人数',
            align:"center",
            width:200,
            dataIndex: 'requireQuantity',
            ellipsis: true
          },
          {
            title:'已入职人数',
            align:"center",
            width:200,
            dataIndex: 'docCount',
            ellipsis: true
          },
          {
            title:'空缺人数',
            align:"center",
            width:200,
            dataIndex: 'needCount',
            ellipsis: true
          },
          {
            title:'地点',
            align:"center",
            width:200,
            dataIndex: 'workAddress',
            ellipsis: true
          },
          {
            title:'要求',
            align:"center",
            width:200,
            dataIndex: 'requirements',
            ellipsis: true
          }
        ],
        url: {
          list: "/api/erp/hr/report/requirements/hrReportEmployeeRequirements/list",
          exportXlsUrl: "/api/erp/hr/report/requirements/hrReportEmployeeRequirements/exportXls"
        },
        dictOptions:{},
        superFieldList:[],
        queryParam:{
          month: moment().startOf('month').format("YYYY-MM"),
        }
      }
    },
    created() {
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },

      searchReset() {
        this.queryParam = {
          month: moment().startOf('month').format("YYYY-MM"),
        }
        this.searchQuery()
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>
